Skip to content

G6: CSRF and cookie-flag leads (csrf_cookie_map.py) - #2225

Merged
remigiusz-antczak merged 2 commits into
mainfrom
lane/g6-csrf-cookie
Nov 4, 2026
Merged

remigiusz-antczak merged 2 commits into
mainfrom
lane/g6-csrf-cookie

Conversation

@remigiusz-antczak

Copy link
Copy Markdown
Collaborator

Adds csrf_cookie_map.py, a report-only lead-finder for CSRF-exposed cookie-session handlers and session cookies missing Secure, HttpOnly or SameSite. It is wired into review_checks.sh --full as tool csrf-cookie.

  • Rules:
    • missing-csrf-protection flags a state-changing handler that relies on a session cookie and shows no defence. A defence is a csrf/xsrf token, an Origin, Referer or Sec-Fetch-Site header compared against a literal or an allow-list, or a repo-wide CSRF layer that the repo does not disable. Django @csrf_exempt removes the layer cover.
    • missing-cookie-flags flags a session-like cookie set without one of the three flags.
  • Frameworks: Express/Next, Flask, Django, Go and Spring.
  • Shared code: attempt_limit_map.units gains innermost=False, resolves mid-line Django path() calls, keeps sibling one-line Spring handlers apart, and keeps a multi-line annotation that opens with ({ in its handler's unit. On the six dev fixtures, cost_limit_map, attempt_limit_map and route_auth_map give byte-identical output to main (0 diffs out of 18 runs).
  • Report rule: whole-project-report.md asks for one finding per vulnerable site.
  • Dev numbers: these come from the G6 dev set, which the tool was built against, so treat them as an upper bound. CSRF finds 12/12 positives and flags 0/8 decoys; cookie flags find 12/12 and flag 0/8. A blind set is the real measure and is not run yet.
  • Review: three independent review rounds were folded in. Each has its own regression test file: test_csrf_cookie_map.py, test_csrf_cookie_review.py and test_csrf_cookie_round2.py.

Tests: 71/71 across the csrf-cookie, attempt-limit, cost-limit and route-auth suites. run-ci-tests.sh --affected passes 56/56 suites, and regen, size-ratchet, fragments and pre-commit are green.

🤖 Generated with Claude Code

remigiusz-antczak and others added 2 commits November 4, 2026 07:11
New report-only tool csrf_cookie_map.py, wired into review_checks.sh
--full as tool csrf-cookie, with two rules:

- missing-csrf-protection: a state-changing handler in a cookie-session
  file or path realm whose own text shows no anti-forgery defence (csrf or
  xsrf, or an Origin/Referer/Sec-Fetch-Site header compared against a
  literal or an allow-list), and no repo-wide CSRF layer that the repo does
  not disable. Django @csrf_exempt removes the layer cover. Reported at the
  line that commits the change.
- missing-cookie-flags: a session-like cookie set without Secure, HttpOnly
  or SameSite (Go, Express, Flask/Django, Java Cookie and ResponseCookie,
  raw Set-Cookie strings). Expiry, csrf-named and variable-options cookies
  are skipped.

attempt_limit_map.units gains innermost=False (Go wrapper registrations
resolve to the inner handler only when asked), resolves mid-line Django
path() calls, keeps sibling one-line Spring handlers apart and keeps a
multi-line annotation that opens with `({` in its handler's unit. Output of
cost_limit_map, attempt_limit_map and route_auth_map on the six dev
fixtures is byte-identical to main.

whole-project-report.md asks for one finding per vulnerable site.

Dev set only (the tool was built against these fixtures, so this is an
upper bound): csrf 12/12 positives, 0/8 decoys; cookie_flags 12/12, 0/8.
Three independent review rounds folded. run-ci-tests.sh --affected: 56/56
suites pass.

Tests: 71/71
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tests: 71/71

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@remigiusz-antczak
remigiusz-antczak merged commit 6673494 into main Nov 4, 2026
11 checks passed
@remigiusz-antczak
remigiusz-antczak deleted the lane/g6-csrf-cookie branch November 4, 2026 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant